package com.zl.cms.web;

import com.zl.cms.auth.AuthUtil;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;

import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import java.util.Map;
import java.util.Set;

/**
 * User: zl email:c3tc3tc3t@126.com Date: 14-3-6 Time: 上午8:47
 */
public class InitServlet extends HttpServlet {
  private static WebApplicationContext context;

  @Override
  public void init(ServletConfig config) throws ServletException {
    super.init(config);
    // 初始化spring工厂
    context = WebApplicationContextUtils.getWebApplicationContext(this.getServletContext());
    // 初始化权限信息
    Map<String, Set<String>> auths = AuthUtil.initAuth("com.zl.cms.controller");
	  this.getServletContext().setAttribute("allAuths",auths);
	  System.out.println("____________init Success  "+auths+"______________");
  }

  public static WebApplicationContext getContext() {
    return context;
  }
}
